﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AdapterPattern
{
    /// <summary>
    /// 目标抽象类
    /// </summary>
    interface Target
    {
        void Request();
    }

    /// <summary>
    /// 适配者类
    /// </summary>
    class Adaptee
    {
        public void SpecificRequest()
        {
            Console.WriteLine("我是适配器");
        }
    }


    //class Adapter : Adaptee, Target
    //{
    //    public void Request()
    //    {
    //        base.SpecificRequest();
    //    }
    //}

    /// <summary>
    /// 适配器类
    /// </summary>
    class Adapter : Target
    {
        public Adaptee adaptee;

        public Adapter(Adaptee adaptee)
        {
            this.adaptee = adaptee;
        }

        public void Request()
        {
            adaptee.SpecificRequest();
        }
    }



    class Program
    {
        static void Main(string[] args)
        {
            var dateTime = DateTime.Now.ToString("F");

            Adaptee adaptee = new Adaptee();

            Adapter adapter = new Adapter(adaptee);
            adapter.Request();

        }
    }
}
